package logic

import (
	"context"
	"fmt"
	"order_srv/pkg"

	"order_srv/internal/svc"
	"order_srv/order_srv"

	"github.com/zeromicro/go-zero/core/logx"
)

type AliPayLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewAliPayLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AliPayLogic {
	return &AliPayLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *AliPayLogic) AliPay(in *order_srv.AliPayRequest) (*order_srv.AliPayResponse, error) {
	// todo: add your logic here and delete this line
	amount := fmt.Sprintf("%.2f", in.Amount)
	pay := pkg.NewAliPayClient().Pay(in.Title, in.OrderSn, amount)
	return &order_srv.AliPayResponse{UrlImg: pay}, nil
}
